using System;
using System.Collections.Generic;
using System.Web;
using System.Text;

namespace CommunityServerStuff.HttpModules
{
    class DomainRewriteModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(System.Web.HttpApplication context)
        {
            context.BeginRequest += new EventHandler(CheckURL);
        }

        public void CheckURL(object sender, EventArgs e)
        {
            HttpApplication app = ((HttpApplication)(sender));
            string url = app.Request.Url.ToString().ToLower();
            string host = "longhornblogs.com";
            if (url.Contains(host))
            {
                HttpContext.Current.Response.StatusCode = 301;
                HttpContext.Current.Response.Redirect(url.Replace(host, "windows-now.com/blogs"));
                
            }
        } 
    }
}
